package com.sirun.cn.fca.module.main.home.temp;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.sirun.cn.fca.R;
import com.sirun.cn.fca.module.main.home.temp.control.constant.ControlIntentConst;
import com.sirun.cn.fca.module.main.home.temp.control.constant.PathConst;
import com.tencent.cloud.iov.flow.view.IContentViewContainer;
import com.tencent.cloud.iov.recycler.flow.BaseRecyclerFlowView;
import com.tencent.cloud.iov.router.Router;

public class HomeFlowView extends BaseRecyclerFlowView<HomeContract.Presenter> implements HomeContract.View {
    private static final String TAG = "HomeFlowView";

    public HomeFlowView(Activity activity) {
        super(activity);
    }

    public HomeFlowView(Activity activity, IContentViewContainer container) {
        super(activity, container);
    }

    @Override
    protected RecyclerView createRecyclerView() {
        RecyclerView view = super.createRecyclerView();
        view.setBackgroundResource(R.drawable.page_bg_gradient);
        return view;
    }

    @Override
    protected HomeContract.Presenter createPresenter() {
        return new HomeFlowPresenter();
    }

    @Override
    public void onMessageClicked() {
    }

    @Override
    public void onLockClicked() {
        pinIntent(ControlIntentConst.LOCK);
    }

    @Override
    public void onUnLockClicked() {
        pinIntent(ControlIntentConst.UNLOCK);
    }

    @Override
    public void onBeerClicked() {
        pinIntent(ControlIntentConst.BEER);
    }

    @Override
    public void onEngineOnClicked() {
        pinIntent(ControlIntentConst.ENGINE_ON);
    }

    @Override
    public void onEngineOffClicked() {
        pinIntent(ControlIntentConst.ENGINE_OFF);
    }

    private void pinIntent(int type) {
        String path = PathConst.PIN;
        Intent pinIntent = Router.fromPath(path);
        pinIntent.putExtra(ControlIntentConst.FROM, type);
        getActivity().startActivity(pinIntent);
    }

}
